#ifndef _BORAD_H_
#define _BORAD_H_

#include "dmu.h"
#include "hardwire.h"
#include "mcu.h"
#include "typedef.h"

#define BSP_MCU_MODEL             POLSYS_MCU_CMS32F0301          // MCU型号
#define Board_GetTickCycleValue() SYSTICK_VALUE                  // Systick周期值
#define Board_GetTickNowValue()   (SYSTICK_VALUE - SysTick->VAL) // SysticK当前值
#define Board_GetDcIn()           DCIN_PIN_IN                    // 充电检测引脚
#define Board_VExtOn()            VEXT_ON                        // 开启外设电源
#define Board_VExtOff()           VEXT_OFF                       // 关闭外设电源

void Board_Init();

bool Board_LcdSpiSend(const u8* t_buff, size_t len);

bool Board_FlashSpiReceive(u8* r_buff, size_t len);

bool Board_FlashSpiSend(const u8* t_buff, size_t len);

// 获取本机电池电压 mV
u16 Board_GetVBat();

// LCD断电
void Board_LcdPowerOff(void);

// LCD上电
void Board_LcdPowerOn(void);

#define Board_StartFlashSpiCs() FLASH_CS_PIN_OUT = 0

#define Board_StopFlashSpiCs() FLASH_CS_PIN_OUT = 1

#define Board_StartLcdSpiCs() LCD_CS_PIN_OUT = 0

#define Board_StopLcdSpiCs() LCD_CS_PIN_OUT = 1

/**
 * 向LCD发数据
 * @return true:操作成功
 */
#define Board_LcdSpiSend(t_buff, len) Spi_SendSync(t_buff, len)

/**
 * 向FLASH发送或者从FLASH接收数据
 * @return true:操作成功
 */
#define Board_FlashSpiReceive(r_buff, len) Spi_Trans(r_buff, NULL, len)

#define Board_FlashSpiSend(t_buff, len) Spi_SendSync(t_buff, len)

// 休眠
void Board_Sleep();

// 负载状态获取：true-有负载
bool Board_GetLoadStatus();

void Board_ResetToBl();

#endif
